import request from './request'

// 创建活动
export function createActivity(data) {
  return request.post('/activities', data)
}

// 更新活动
export function updateActivity(id, data) {
  return request.put(`/activities/${id}`, data)
}

// 删除活动
export function deleteActivity(id) {
  return request.delete(`/activities/${id}`)
}

// 获取活动详情
export function getActivityDetail(id) {
  return request.get(`/activities/${id}`)
}

// 分页查询活动列表
export function getActivityList(params) {
  return request.get('/activities/page', params)
}

// 获取即将开始的活动
export function getUpcomingActivities(limit) {
  return request.get('/activities/upcoming', { limit })
}

// 获取热门活动
export function getHotActivities(limit) {
  return request.get('/activities/hot', { limit })
}

// 获取用户已报名的活动
export function getUserRegisteredActivities(params) {
  return request.get('/activities/user/registered', params)
}

// 获取用户创建的活动
export function getUserCreatedActivities(params) {
  return request.get('/activities/user/created', params)
}

// 参加活动
export function joinActivity(activityId) {
  return request.post(`/activities/${activityId}/join`)
}

// 取消参加活动
export function cancelActivity(activityId) {
  return request.post(`/activities/${activityId}/cancel`)
}

// 获取活动参与者列表
export function getActivityParticipants(activityId, params = {}) {
  return request.get(`/activities/${activityId}/participants`, params)
}

// 上传活动图片
export function uploadActivityImage(formData) {
  return request.upload('/activities/upload', formData)
}